package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Println("請輸入需要操作的目錄：")
	var path string
	fmt.Scan(&path)

	dir, err := os.OpenFile(path, os.O_RDONLY, os.ModeDir)
	if err != nil {
		println("目錄打開錯誤")
		return
	}
	defer dir.Close()
	file, err := dir.ReadDir(-1)
	if err != nil {
		println("錯誤")
		return
	}
	for _, fileordir := range file {
		println(fileordir.Name())
	}
}
